export class AppError extends Error {
  constructor(
    message: string,
    public code: string,
    public recoverable: boolean = true
  ) {
    super(message);
    this.name = 'AppError';
  }
}

export class NetworkError extends AppError {
  constructor(message: string = '网络连接失败') {
    super(message, 'NETWORK_ERROR', true);
  }
}

export class ConfigError extends AppError {
  constructor(message: string = '配置文件错误') {
    super(message, 'CONFIG_ERROR', true);
  }
}

export class AIServiceError extends AppError {
  constructor(message: string = 'AI服务错误') {
    super(message, 'AI_SERVICE_ERROR', true);
  }
}

export class ValidationError extends AppError {
  constructor(message: string = '输入验证失败') {
    super(message, 'VALIDATION_ERROR', false);
  }
}

export class MemoryError extends AppError {
  constructor(message: string = '内存不足') {
    super(message, 'MEMORY_ERROR', true);
  }
}